﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using TCKQKL.FrontEnd.DataModel;
using TCKQKL.FrontEnd.Config;
using TCKQKL.Service.LookupClient;

namespace TCKQKL.FrontEnd.Web.Controls
{
    public partial class Portfolio : System.Web.UI.UserControl
    {
        public TotalHoldingDataUI holdings = new TotalHoldingDataUI();

        protected void Page_Load(object sender, EventArgs e)
        {
            string userid = HttpContext.Current.User.Identity.Name;
            if (userid == "")
            {
                HttpCookie authcookie = Request.Cookies[FormsAuthentication.FormsCookieName];
                if (authcookie==null)
                {
                    FormsAuthentication.SignOut();
                    Response.Redirect(Settings.URL_PAGE_LOGIN);
                }
                FormsAuthenticationTicket ticket = (FormsAuthenticationTicket)FormsAuthentication.Decrypt(authcookie.Value);
                userid = ticket.Name;
            }
            LSClient client = new LSClient();
            holdings = client.getTotalHolding(client.getAccountData(HttpContext.Current.User.Identity.Name).investorId);
            client.Close();
        }
    }
}